﻿using System.Collections.Generic;
using Microsoft.CodeAnalysis;

namespace Beeflys.Generator
{
    static class ITypeSymbolEx
    {
        public static IType AsUtype(this ITypeSymbol symbol, List<string> imports, Reflect reflect)
        {
            string fullName = symbol.ToString();
            if (reflect.Mapper.Contains(fullName))
            {
                return reflect.Mapper.Get(fullName);
            }
            
            var utype = UTypeHelper.Create(symbol, imports, reflect);
            reflect.Mapper.Add(utype);
            
            return utype;
        }
    }
}